import { contextBridge, ipcRenderer } from 'electron'

// 暴露安全的 API 给渲染进程
contextBridge.exposeInMainWorld('electronAPI', {
  // 窗口管理
  openNewWindow: (options) => ipcRenderer.invoke('open-new-window', options),
  openModalWindow: (options) => ipcRenderer.invoke('open-modal-window', options),
  getWindowsInfo: () => ipcRenderer.invoke('get-windows-info'),
  closeWindow: (windowId) => ipcRenderer.invoke('close-window', windowId),

  // 调试功能
  openDevTools: () => ipcRenderer.invoke('open-dev-tools'),
  closeDevTools: () => ipcRenderer.invoke('close-dev-tools'),
  toggleDevTools: () => ipcRenderer.invoke('toggle-dev-tools'),
  openDevToolsForWindow: (windowId) => ipcRenderer.invoke('open-dev-tools-for-window', windowId),
  getDebugInfo: () => ipcRenderer.invoke('get-debug-info'),

  // 其他工具函数
  versions: {
    node: process.versions.node,
    chrome: process.versions.chrome,
    electron: process.versions.electron,
  },
})
